package cn.pomelo.activity.controller;

import cn.pomelo.activity.model.Item;
import cn.pomelo.activity.model.Question;
import cn.pomelo.activity.service.IItemService;
import cn.pomelo.activity.service.IQuestionService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@RestController()
@CrossOrigin("*")
public class IndexController {

    @Resource
    IQuestionService questionService;

    @Resource
    IItemService itemService;

    @GetMapping("/index")
    public ModelAndView index() {
        return new ModelAndView("index.html");
    }

    @RequestMapping("/group")
    public ModelAndView group() {
        return new ModelAndView("group.html");
    }

    @RequestMapping("/question")
    public ModelAndView question() {
        return new ModelAndView("question-index.html");
    }

    @RequestMapping("/item")
    public ModelAndView item() {
        return new ModelAndView("item-index.html");
    }

    @RequestMapping("/questions")
    public ModelAndView questions() {
        return new ModelAndView("questions.html");
    }

    @RequestMapping("/items")
    public ModelAndView items() {
        return new ModelAndView("item.html");
    }

    @RequestMapping("/mlgm")
    public ModelAndView mlgm() {
        return new ModelAndView("mlgm.html");
    }

    @RequestMapping("/contend")
    public ModelAndView contend() {
        return new ModelAndView("contend.html");
    }

    @RequestMapping("/reward")
    public ModelAndView reward() {
        return new ModelAndView("reward.html");
    }

    @RequestMapping("/power")
    public ModelAndView power() {
        return new ModelAndView("power.html");
    }

    @RequestMapping("/getAllQuestions")
    public List<Question> getAllQuestions() {
        return questionService.findAll();
    }

    @RequestMapping("/getAllItems")
    public List<Item> getAllItems() {
        return itemService.findAll();
    }

    @RequestMapping("/xh")
    public String xh() {
        return "xh";
    }

}
